//
//  NSDate+Utilities.h
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 BaseBusiness. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSDate (Utilities)

/**
 * 获取日、月、年、小时、分钟、秒
 */
- (NSUInteger)day;
- (NSUInteger)month;
- (NSUInteger)year;
- (NSUInteger)hour;
- (NSUInteger)minute;
- (NSUInteger)second;
+ (NSUInteger)day:(NSDate *)date;
+ (NSUInteger)month:(NSDate *)date;
+ (NSUInteger)year:(NSDate *)date;
+ (NSUInteger)hour:(NSDate *)date;
+ (NSUInteger)minute:(NSDate *)date;
+ (NSUInteger)second:(NSDate *)date;

/**今天*/
- (BOOL) isToday;
/** Yesterday */
- (BOOL) isYesterday;
/**this week*/
- (BOOL) isThisWeek;
/**校验是否相差七天*/
- (BOOL) isContain7day;
/**this Year*/
- (BOOL) isThisYear;
/**星期几*/
- (nullable NSString *)weekDay;

+ (NSString*)getIMDateTimeWithTimeSpace:(long long)sentTime;

+ (NSString*)getDateTimeWithTimeSpace:(long long)sentTime;

- (NSInteger)hoursBeforeDate:(NSDate *)aDat;

+ (long long )getBeforeDateTime:(long long)beforeTime nextTime:(long long)nextTime;

//日期格式化
- (NSString *)stringWithFormat:(NSString *)format;

//字符串转换成时间
+ (NSDate *)dateFromString:(NSString *)string withFormat:(NSString *)format;

//根据日期计算星座
+ (NSString *)getAstroWithMonth:(NSInteger)m day:(NSInteger)d;

///计算年龄
+ (NSInteger)ageWithDateOfBirth:(NSDate *)date;
/// 时间戳转字符串
+ (NSString *)dateFormatTimeInterval:(NSTimeInterval)timeInterval;
/// 时间戳转字符串 yyyy-MM-dd HH:mm:ss 根据样式
+ (NSString *)getTimeInterval:(NSTimeInterval)timeInterval  formatter:(NSString *)formatter;

#pragma mark 获取时间戳
+ (NSTimeInterval)getNowTimeInterval;

@end

NS_ASSUME_NONNULL_END
